package com.portal.system.api.factory;

import com.portal.common.core.domain.R;
import com.portal.system.api.RemoteMqService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * MQ服务降级处理
 * 
 * @author portal
 */
@Component
public class RemoteMqFallbackFactory implements FallbackFactory<RemoteMqService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteMqFallbackFactory.class);

    @Override
    public RemoteMqService create(Throwable throwable)
    {
        log.error("文件服务调用失败:{}", throwable.getMessage());
        return new RemoteMqService()
        {
            @Override
            public R<String> sendMessage(String exchange,
                                         String routingKey,
                                         String message,
                                         String queue,
                                         String source) {
                return R.fail("发送消息失败:" + throwable.getMessage());
            }

        };
    }
}
